'use strict';
angular.module('bookApp').controller('BookCtrl', function($scope, $rootScope, $http, $log, $filter, $modal, $location, $state) {
	$scope.logout = function() {
		var logoutForm = $('#logout-form');
		logoutForm.submit();
	};


});

angular.module('bookApp').controller('loginCtrl', function($scope, $rootScope, $http, $log, $location, $cookieStore) {
	$scope.user = $cookieStore.get("user");
	$scope.disabled_logon = false;
	$scope.logonFailures = 0;
	$scope.code = "";

	$scope.login = function(valid) {
		if ($scope.user.rememberMe)
			$cookieStore.put("user", {
				username : $scope.user.username,
				rememberMe : $scope.user.rememberMe
			});
		else {
			$cookieStore.remove("user");
		}
		if (valid)
			login_form.submit();
		return false;
	}


});

angular.module('bookApp').controller('loginErrorModelCtrl', function($scope, $rootScope, $http, $log, $filter, $modalInstance) {
	$scope.ok = function() {
		$modalInstance.close();
	}
});
